﻿package at.geoathome.ui.buttons
{
	import  at.geoathome.ui.buttons.Button;
	import flash.events.MouseEvent;

	/**
	* ...
	* @author Georg Kamptner
	*/
	public class Checkbox extends Button
	{
		
		public function Checkbox(bg_classname:String = Button.INVISIBLE_BACKGROUND, auto_check:Boolean = true) 
		{
			super(bg_classname);
			
			// add event listener to check and uncheck the checkbox automatically
			if(auto_check)
				this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
		}
		
		public function get checked():Boolean {
			return _activated;
		}
		
		public function set checked(checked:Boolean):void {
			if (checked)
				activate()
			else
				deactivate();
		}
		
		protected function onMouseDown(e:MouseEvent):void
		{
			checked = !checked;
		}
	}
	
}